package com.smartlifev30.baiwei.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.smartlifev30.R;
import com.smartlifev30.baiwei.adapter.TestAdapter;
import com.smartlifev30.baiwei.bean.Scene;
import com.smartlifev30.baiwei.view.PlateView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class test extends AppCompatActivity {

    private ProgressBar pb;
    private RecyclerView rv;
    private ExpandableListView exLv;
    private PlateView plantView;


    HashMap<String, List<String>> data = new HashMap();
    private ArrayList<String> parent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        plantView = findViewById(R.id.plateView);
        plantView.setSelectedListen((view, position) -> {
            Toast.makeText(test.this, String.valueOf(position), Toast.LENGTH_SHORT).show();
        });
        exLv = findViewById(R.id.ex_lv);

         parent = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 10; j++) {
                List<String> strings = data.get(String.valueOf(i));
                if (strings == null) {
                    strings = new ArrayList<>();
                    strings.add(String.valueOf(j));
                    data.put(String.valueOf(i), strings);
                } else {
                    strings.add(String.valueOf(j));
                }
            }
            parent.add(String.valueOf(i));
        }


        exLv.setAdapter(new TestAdapter(this, parent,data));
        exLv.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                Log.e("0-0-", groupPosition + " - " + id);
                return false;
            }
        });
        exLv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
                Log.e("0-0-", groupPosition + " - " + childPosition + " -" + id);
                return false;
            }
        });
    }


    public void aaa(View view) {
        Toast.makeText(this, "aaaaa", Toast.LENGTH_SHORT).show();
    }
}
